package com.yuneec.droneservice.request;

/**
 * Created by zd.zhang on 2017/9/11.
 */

public class IResponse<O> {
    private int id;
    private int code;
    private O obj;

    public IResponse(int id, int code) {
        this.id = id;
        this.code = code;
    }

    public int ids() {
        return id;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof IResponse)) {
            return false;
        }
        IResponse oo = (IResponse) o;
        return ids() == oo.ids() && code == oo.code && obj.equals(oo.obj);
    }

    public void setParam(O obj) {
        this.obj = obj;
    }

    public O getParam() {
        return obj;
    }

    @Override
    public String toString() {
        return String.format("id:%d  code:%d  context:%s", id, code, obj == null ? "null" : obj.toString());
    }
}
